import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

/**
 * remove the selected component
 * 
 * @author Ronny
 * 
 */

public class RemoveAction extends AbstractAction {

	private static final long serialVersionUID = 1L;
	private KomMap kommap;
	/**
	 * the names are used to tell the new reference points and the old ones from
	 * server;
	 */
	public String nameRef;
	public String nameRefSer;

	RemoveAction(KomMap kommap) {
		this.kommap = kommap;
		// this.putValue( Action.NAME, RemoveAction.NAME);
		// this.putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("D"));
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub

		if (nameRef == "Remove") {

			// mousePosition ist ungenau ,muss instanz geben
			kommap.komMapPane.remove(PopupListener.selectedref);
			// send remove information to the server
			kommap.guiController.removeRefPoint(PopupListener.xpos,
					PopupListener.ypos);
	        // the removed reference point should not be sent to server
			PopupListener.xpos=-10;
			PopupListener.ypos=-10;
		
			kommap.komMapPane.repaint();
		}

		if (nameRefSer == "RemoveReffromServer") {

			// mousePosition ist ungenau ,muss instanz geben
			kommap.komMapPane.remove(PopupListener.selectedref);
			// send remove information to the server
			kommap.komMapPane.repaint();

			kommap.guiController.removeRefPoint(PopupListener.xpos,
					PopupListener.ypos);
		}

	}

}
